// reduce + concat + 递归

Array.prototype.myFlat = function(deep){
    if(deep<=0) return this
    let res = [...this]
    res=res.reduce((n,l)=>{
        return Array.isArray(l) ? n.concat(l.myFlat(--deep)) : n.concat(l) 
    },[])
    return res
}
let test = [1,2,3,[4,5,[6,7]]]

console.log(test.myFlat(1));